<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="beans.Operation"%>
<%@page import="beans.Drug"%>
<%@page import="beans.OutPatient"%>
<%@page import="java.util.ArrayList"%>
<html dir="ltr" xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml"
	lang="en-gb">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta name="robots" content="index, follow">
		<meta name="keywords" content="joomla, Joomla">
			<meta name="description"
				content="Joomla! - the dynamic portal engine and content management system">
				<meta name="generator"
					content="Joomla! 1.5 - Open Source Content Management">
					<title>Welcome to the Mountain View Community Hospital</title>
					<link rel="stylesheet" href="../image/template.css" type="text/css">
						<link rel="stylesheet" href="../image/constant.css"
							type="text/css">

							<!--equal-->
							<!--[if IE]>
   <script type="text/javascript" src="/joomla_24417/templates/theme288/scripts/ie_png.js"></script>
   <script type="text/javascript">
       ie_png.fix('.png');
	</script>
	<STYLE type="text/css">
			.tr{
				cursor:hand;
			}
	</STYLE>
<![endif]-->
							<SCRIPT language="javascript">
								var colorOver = "#a4d3ee";
								var colorClick = "#00ee00"
								var colorNone = "#ffffff";
								var k = 1;

								function clickSet(Obj) {
									var tb = null;
									if (Obj.parentNode.offsetParent.attributes.id.value == "drug") {
										tb = document.getElementById("drug");
									} else if (Obj.parentNode.offsetParent.attributes.id.value == "operation") {
										tb = document
												.getElementById("operation");
									}
									var chooseRowNo = 999;
									for (i = 0; i < tb.rows.length; i++) {
										//			tb.rows[i].bgColor=colorNone;

										if (tb.rows[i] == Obj) {
											chooseRowNo = i;
										}
									}
									if (chooseRowNo != 999) {
										if (tb.rows[chooseRowNo].bgColor == colorClick) {
											tb.rows[chooseRowNo].bgColor = colorNone;
										} else {
											tb.rows[chooseRowNo].bgColor = colorClick;
										}
									}
								}
								function mouseoverSet(Obj) {
									var tb = null;
									if (Obj.parentNode.offsetParent.attributes.id.value == "drug") {
										tb = document.getElementById("drug");
									} else if (Obj.parentNode.offsetParent.attributes.id.value == "operation") {
										tb = document
												.getElementById("operation");
									}
									var mouseoverRowNo = 999;
									for (i = 0; i < tb.rows.length; i++) {
										if (tb.rows[i].bgColor == colorOver)
											tb.rows[i].bgColor = colorNone;
										if (tb.rows[i] == Obj) {
											mouseoverRowNo = i;
										}
									}
									if (mouseoverRowNo != 999
											&& tb.rows[mouseoverRowNo].bgColor != colorClick) {
										tb.rows[mouseoverRowNo].bgColor = colorOver;
									}
								}
								function clearColor(Obj) {
									var tb = document.getElementById("drug");
									for (i = 0; i < tb.rows.length; i++) {
										if (colorOver == tb.rows[i].bgColor) {
											tb.rows[i].bgColor = colorNone;
										}
									}
								}
								function readSelect() {
									var tb = document.getElementById("drug");
									for (i = 0; i < tb.rows.length; i++) {
										if (tb.rows[i].bgColor == colorClick) {
											getTableContent(i,tb);
										}
									}
									
									tb = document.getElementById("operation");
									for (i = 0; i < tb.rows.length; i++) {
										if (tb.rows[i].bgColor == colorClick) {
											getTableContent(i,tb);
										}
									}

									var s = document.getElementById("visit");
									var pa = document.getElementById("pa");
									pa.value = s[s.selectedIndex].text;
								}
								function cInput(vl, prefix) {
									var element = document
											.createElement("input");
									var oForm = document.getElementById("f");
									element.setAttribute("type", "text");
									element.setAttribute("value", vl);
									element.setAttribute("name", (prefix + k));
									oForm.appendChild(element);
									k = k + 1;
								}
								function getTableContent(rowIndex,node) {
									if (node.attributes.id.value == "drug") {
										var child = node
												.getElementsByTagName("tr")[rowIndex];
										cInput(child.childNodes[0].textContent,
												"d");
										cInput(
												child.childNodes[2].children[0].value,
												"d");
									} else if (node.attributes.id.value == "operation") {
										var child = node
												.getElementsByTagName("tr")[rowIndex];
										cInput(child.childNodes[0].textContent,
												"o");
									}
								}
							</SCRIPT>
</head>
<body id="body">
	<!--header-->
	<div class="tail-logo">
		<div class="tail-right"></div>
		<div class="main">
			<div class="row-logo">
				<h1 style="font-size: 30px; color: white;">Mountain View
					Community Hospital</h1>
			</div>
		</div>
	</div>
	<div class="tail-header">
		<div class="main">
			<div class="header">
				<div class="fright">
					<div class="row-1">
						<div class="moduletable">
							<img src="../image/header_link_img_1.gif" alt=""> <img
								src="../image/header_link_img_2.gif" alt=""> <img
									src="../image/header_link_img_3.gif" alt=""> <img
										src="../image/header_link_img_4.gif" alt=""> <img
											src="../image/header_link_img_5.gif" alt="">
						</div>
					</div>

				</div>

				<div class="clear1"></div>
			</div>
		</div>
	</div>
	<div class="tail-row-top-menu clear">
		<div class="main">
			<div class="row-top-menu clear">
				<div class="fright">
					<div class="module" style="text-align: right; margin-top: 15px;">
						<h4>${accountID},${role},${personID}<a href="/project/resources/common/login.htm">Logout</a></h4>


					</div>

				</div>
				<div class="fleft">
					<div class="module-search"></div>
				</div>
			</div>
		</div>
	</div>
	<div class="tail-content clear">
		<div class="main">
			<!--content-->
			<div id="content">
				<div class="clear">
					<!--left-->
					<div id="left">
						<div class="left-indent">
							<div class="clear">
								<div class="wrapper-menu module_menu" style="padding: 0;">
									<div class="wrapper-menu-width">
										<div class="border-top">
											<div class="border-left">
												<div class="border-right">
													<div class="corner-top-left">
														<div class="corner-top-right">
															<table style="width: 100%;" class="width">
																<tbody>
																	<tr>
																		<td class="width extra-height">
																			<div class="clear">
																				<div class="box-title">
																					<h3
																						style="padding: 27px 0 0 32px; color: #FFF; font-size: 14px; font-family: Georgia,"TimesNewRoman", Times, serif">Main
																						menu:</h3>
																				</div>
																				<div class="wrapper-menu-box">
																					<div class="clear">
																						<ul class="menu" style="padding: 0 32px 22px 31px">
																							<li id="current" class="active item1"><a
																								href="http://www.drame.cn/joomla_24417/"><span>Add</span></a></li>
																							<li class="item2"><a
																								href="http://www.drame.cn/joomla_24417/index.php?option=com_content&amp;view=article&amp;id=5&amp;Itemid=2"><span>View</span></a></li>
																							<li class="item58"><a
																								href="http://www.drame.cn/joomla_24417/index.php?option=com_content&amp;view=category&amp;layout=blog&amp;id=1&amp;Itemid=58"><span>Report</span></a></li>
																						</ul>
																					</div>
																				</div>
																			</div>
																		</td>
																	</tr>
																</tbody>
															</table>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>



							</div>
						</div>
					</div>
					<!--center-->
					<div id="container">
						<div class="container-indent">
							<div class="row-box clear">
								<div class="clear wrapper-box-extra module s2"
									style="width: 548px">
									<div class="box-title">
										<div class="bull-title png">
											<h3>Add Treatment</h3>
										</div>
									</div>
									<div>
										<div class="box-indent">
											<div style="height: 500px;" class="clear equal">
												<div>
													<p style="color: #002C4B; font-size: 14px;">
														Select Visit: <select name="visit" id="visit">

															<%
																int i = 0;
																ArrayList<OutPatient> outPatientList = (ArrayList) request.getSession()
																		.getAttribute("outPatientList");

																for (OutPatient outPatient : outPatientList) {
																	out.print("<option value=" + i + ">"
																			+ outPatient.getPatientID() + ", "
																			+ outPatient.getVisit_date() + "</option>");
																}
															%>

														</select>
													</p>
													<p>&nbsp;</p>
												</div>
												<div
													style="width: 300px; height: 150px; overflow: hidden; overflow-y: scroll">
													<table border="1" id="drug">
														<tr>
															<th>DrugID</th>
															<th>Description</th>
															<th>Quantity</th>
														</tr>
														<%
															int j = 0;
															ArrayList<Drug> drugList = (ArrayList) request.getSession()
																	.getAttribute("drugList");
															for (Drug drug : drugList) {
																out.print("<tr onClick=\"clickSet(this)\" onMouseOver=\"mouseoverSet(this)\" onMouseOut=\"clearColor(this)\" class=\"tr\"><td>"
																		+ drug.getDrugID() + "</td>");
																out.print("<td>" + drug.getDescription() + "</td>");
																/*out.print("<td><select name=\"d"
																		+ j
																		+ "\" id=\"d"
																		+ j
																		+ "\"><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option></select></td>");
																out.print("</tr>");*/
																out.print("<td><input type=\"text\" name=\"num\" style=\"width:50px;\" ></td>");
															}
														%>
													</table>
													<p>&nbsp;</p>
												</div>
												<br>
												</br>
												<br>
												</br>
												<div
													style="width: 300px; height: 250px; overflow: hidden; overflow-y: scroll">
													<table border="1" id="operation">
														<tr>
															<th>OperationID</th>
															<th>Description</th>
														</tr>
														<%
															ArrayList<Operation> opList = (ArrayList) request.getSession()
																	.getAttribute("operationList");
															for (Operation operation : opList) {
																out.print("<tr onClick=\"clickSet(this)\" onMouseOver=\"mouseoverSet(this)\" onMouseOut=\"clearColor(this)\" class=\"tr\"><td>"
																		+ operation.getOperationID() + "</td>");
																out.print("<td>" + operation.getDescription() + "</td>");
																out.print("</tr>");
															}
														%>
													</table>
													<p>&nbsp;</p>
												</div>

											</div>
										</div>
									</div>
								</div>

							</div>
							<div class="clear">

								<table class="blog" cellpadding="0" cellspacing="0">
									<tbody>
										<tr>
											<td valign="top">
												<div>


													<div class="article-indent">
														<div class="clear">
															<table class="contentpaneopen">
																<tbody>

																	
																</tbody>
															</table>
														</div>
													</div>
													<div class="article-separator-indent">
														<span class="article_separator">&nbsp;</span>
													</div>

												</div>

											</td>
										</tr>



									</tbody>
								</table>

							</div>
						</div>
					</div>
				</div>
			</div>

		</div>
	</div>
	<div>

		<form id="f" action="/project/AddTreatment" method="post">
			<input type="hidden" name="pa" id="pa" /> <input

				onClick="readSelect()" type="submit" id="submit" value="Submit">
		</form>
	</div>
</body>
</html>